import time
from dama import Dama
from PIL import Image
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Edge()
driver.maximize_window()
driver.get('http://49.233.83.37:8080/jeewms/')

#用户名  name="userName"
username=driver.find_element(By.NAME,'userName')
username.clear()
username.send_keys('admin')
#密码 name="password"
password=driver.find_element(By.NAME,'password')
password.clear()
password.send_keys('yan030220@')

#验证码
datu=driver.save_screenshot('datu.png')
yzm=driver.find_element(By.XPATH,'//*[@id="randCodeImage"]')
time.sleep(2)
location=yzm.location
print(location)
size=yzm.size
print(size)

left=location['x']
top=location['y']
right=left+size['width']
bottom=top+size['height']
Image = Image.open('datu.png')
Image1 = Image.crop((left*1.75,top*1.75,right*1.75 ,bottom * 1.75))
Image1.save('image2.png')

# dm=Dama('yjj030220 ','d0ur1r6m','971195')
# yzmdm=open('image2.png','rb').read()
# jieguo=dm.PostPic(yzmdm,1902)
# print(jieguo)
# result=jieguo['pic_str']
# print("我的打码结果是：",result)
# # 输入验证码
# driver.find_element(By.ID,'randCode').send_keys(result)
# time.sleep(2)
# # 点击登录
# driver.find_element(By.ID,'but_login').click()
# time.sleep(3)
# driver.quit()